package lex.title;

import java.awt.Dimension;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.plaf.ButtonUI;

public class WindowButton extends JButton {
	public WindowButton(ButtonUI ui) {
		super();
		super.setUI(ui);
		// =============================
		this.setBorderPainted(false);
		this.setContentAreaFilled(false);
		this.setFocusPainted(false);
		this.setFocusable(false);
		this.setOpaque(false);
		this.setRolloverEnabled(true);
		// ==========================================
		this.setSize(ui.getPreferredSize(this));
	}

	public WindowButton(ButtonUI ui, Action action) {
		this(ui);
		this.setAction(action);
	}

	protected void setUIAndAction(ButtonUI ui, Action action) {
		super.setUI(ui);
		this.setAction(action);
	}

	public Dimension getMinimumSize() {
		return this.getPreferredSize();
	}

	public Dimension getPreferredSize() {
		return ui.getPreferredSize(this);
	}

	/**
	 * refuse to change ui
	 */
	public void setUI(ButtonUI ui) {
	}
}
